package com.nd.sdp.android.scope2;

import com.nd.sdp.android.scope2.di.DaggerPersonComponent;
import com.nd.sdp.android.scope2.di.DemoScope;
import com.nd.sdp.android.scope2.di.PersonComponent;
import com.nd.sdp.android.scope2.fly.IFly;
import com.nd.sdp.android.scope2.ride.IRide;

import javax.inject.Inject;

public class Person {

    @Inject
    @DemoScope
    IFly fly;
    @Inject
    IRide ride;

    @Inject
    Person() {
    }

    private void flyAndRide() {
        System.out.println(fly);
        fly.fly();
        ride.ride();
    }

    public static void main(String[] args) {
        PersonComponent personComponent = DaggerPersonComponent.builder()
                .build();
        Person person = new Person();
        personComponent
                .inject(person);
        person.flyAndRide();
        Person person2 = new Person();
        personComponent
                .inject(person2);
        person2.flyAndRide();
    }

}
